export class AppParams {
    static COMPONENTS_TYPES = {
        VInputsInput: 'VInputsInput'
    }
    static DRIVER_TYPE_PLC = 'PLC'
    static API_TYPE_MES = 'MES'
    static NODE_TYPE_PLC_READ = this.DRIVER_TYPE_PLC + '_READ'
    static NODE_TYPE_PLC_WRITE = this.DRIVER_TYPE_PLC + '_WRITE'
    static NODE_TYPE_MES_MiFindCustomAndSfcData = this.API_TYPE_MES + '_MiFindCustomAndSfcData'
    static NODE_TYPE_MES_MachineIntegration = this.API_TYPE_MES + '_MachineIntegration'

    static DATABASE_TYPE = {
        SQLITE: 'SQLITE',
        MYSQL: 'MYSQL',
        SQL_SERVER: 'SQL_SERVER'
    }

    static NODE_TYPE = {
        LOGIC_SWITCH: 'LOGIC_SWITCH', LOGIC_USER_SCRIPT: 'LOGIC_USER_SCRIPT'
    }
    static DATA_SOURCE_TYPE = {
        NODE: 'NODE',
        GLOBAL_PARAM: 'GLOBAL_PARAM',
        CUSTOM_PARAM: 'CUSTOM_PARAM'
    }

    static PARAM_NAME = {
        SFC: 'SFC', INVENTORY: 'inventory'
    }

    /**
     * 可交互事件
     */
    static INTERACTION_EVENT = [
        {name: '编辑流程', value: 'EDIT_VIEW_FLOW'},
        {name: '用户登录', value: 'USER_LOGIN'},
        {name: '用户登出', value: 'USER_LOGOUT'},
        {name: '数据管理', value: 'DATA_MANAGE'},
        {name: '设备管理', value: 'DEVICE_MANAGE'},
        {name: '全局变量', value: 'GLOBAL_PARAM'},
        {name: '事件管理', value: 'EVENT_MANAGE'},
        {name: '执行流程', value: 'ONCE_RUN'},
        {name: '停止流程', value: 'STOP_PROCESSOR'},
        {name: '系统日志', value: 'OPEN_SYSTEM_LOGGER_FORM'},
    ]

    static JAVA_SCRIPT_EVENT  = {
        ...Object.fromEntries(this.INTERACTION_EVENT.map(s => [s.value, s.value])),
        POST_MESSAGE_BUS: 'POST_MESSAGE_BUS',
        APP_CONFIG_COMPLETED: 'APP_CONFIG_COMPLETED', // 配置信息加载完成
        DEVICE_LOGGER: 'DEVICE_LOGGER',
        NULL: 'NULL',
        UPDATE_FLOW_DATA: 'UPDATE_FLOW_DATA',
        FLOW_LOGGER: 'FLOW_LOGGER', // 流程日志
        FLOW_COMPLETE: 'FLOW_COMPLETE', // 流程完成
        SAVE_FLOW: 'SAVE_FLOW', // 保存流程
        USER_LOGIN_COMPLETED: 'USER_LOGIN_COMPLETED', // 用户登录完成，成功和失败都会触发
        USER_LOGIN_SUCCEEDED: 'USER_LOGIN_SUCCEEDED', // 用户登录成功
        USER_LOGIN_FAILURE: 'USER_LOGIN_FAILURE', // 用户登录失败
        NODE_ERROR: 'NODE_ERROR',
        NODE_LOGGER: 'NODE_LOGGER', // 节点日志
        NODE_STATUS: 'NODE_STATUS', // 节点开始
        NODE_COMPLETE: 'NODE_COMPLETE', // 节点完成事件，只要节点被触发了，不管节点执行成功，失败都会在结束后触发
        NODE_SCRIPT_COMPILE_ERROR: 'NODE_SCRIPT_COMPILE_ERROR', // 脚本编译错误
        SYSTEM_NOTIFICATION: 'SYSTEM_NOTIFICATION', // 系统通知
        NODE_START: 'NODE_START',
        NODE_CLICK: 'NODE_CLICK', // 节点被点击事件
        // NODE_DB_CLICK: 'NODE_DB_CLICK', // 节点被双击事件
        NODE_CANVAS_MOUSE_UP: 'NODE_CANVAS_MOUSE_UP', // 节点的画布被点击事件
        GLOBAL_PARAM_DATA_UPDATE: 'GLOBAL_PARAM_DATA_UPDATE', // 全局变量数据更新
        ALERT: 'alert', // 弹窗事件
        USER_PAGE_ROUTE: 'USER_PAGE_ROUTE', // 界面路由事件
        USER_PAGE: 'USER_PAGE',
        DB_MY_SQL: 'DB_MY_SQL',
        SOCKET_CLIENT: 'SOCKET_CLIENT',
        NODE_ENABLED_DISABLE: 'NODE_ENABLED_DISABLE', // 节点的启用/禁用
        FILE_IO_READ: 'FILE_IO_READ',
        FILE_IO_WRITE: 'FILE_IO_WRITE',
        LOGIC_TRIGGER_FLOW: 'LOGIC_TRIGGER_FLOW', // 触发流程
        LOGIC_CALCULATOR: 'LOGIC_CALCULATOR', // 触发流程
        V_CLICK: 'V_CLICK', // 元素被点击事件
        V_HOVER: 'V_HOVER', // 元素悬浮，获取焦点事件
        UI_REFRESH_TABLE_DATA: 'UI_REFRESH_TABLE_DATA', // 刷新表格数据
        UI_Change_VInputsTab: 'UI_Change_VInputsTab', // 标签选择器组件被点击事件
        UI_Click_VInputsTab: 'UI_Click_VInputsTab', // 标签选择器组件被点击事件
        UI_ADD_ELEMENT_CLASS: 'UI_ADD_ELEMENT_CLASS', // 给元素添加class
        UI_REMOVE_ELEMENT_CLASS: 'UI_REMOVE_ELEMENT_CLASS', // 给元素移除class
    }

    /**
     * type可选，TAB,PAGE,DIALOG
     * @type {{PAGES: [{route: null, title: string, type: string}], ALIGNS}}
     */
    static USER_PAGE = {
        PAGES: [{name: 'default', title: '默认界面', type: 'TAB', route: null}],
        ALIGNS: [
            {
                label: '左对齐',
                value: 'align/leftAlign'
            },
            {
                label: '水平居中',
                value: 'align/centerAlign'
            },
            {
                label: '右对齐',
                value: 'align/rightAlign'
            },
            {
                label: '顶对齐',
                value: 'align/topAlign'
            },
            {
                label: '垂直居中',
                value: 'align/middleAlign'
            },
            {
                label: '底对齐',
                value: 'align/bottomAlign'
            },
            {
                label: '水平等间距',
                value: 'align/horizontalSpacing',
                isDisabled: true
            },
            {
                label: '垂直等间距',
                value: 'align/verticalSpacing',
                isDisabled: true
            }
        ]
    }

    static DESIGNER = {
        OK_NG: 'OK_NG'
    }

    static DEVICE_HUB = [
        {
            title: 'PLC',
            icon: 'PLC',
            list: [
                {DeviceType: 'PLC_S71200', DeviceName: 'PLC-S7-1200', icon: 'PLC_S71200', DeviceModel: 'S71200'}]
        },
        {
            title: '数据库',
            icon: 'database',
            list: [
                {DeviceType: 'DATABASE', DeviceName: '数据库', icon: 'SqlIcon', DeviceModel: 'DATABASE'}
            ]
        },
        {
            title: '通讯管理',
            icon: 'SOCKET_CLIENT',
            list: [
                {
                    DeviceType: 'SOCKET_CLIENT',
                    DeviceName: 'TCP客户端',
                    icon: 'SOCKET_CLIENT',
                    DeviceModel: 'SOCKET_CLIENT'
                },
                {
                    DeviceType: 'SOCKET_SERVER',
                    DeviceName: 'TCP服务端',
                    icon: 'SOCKET_SERVER',
                    DeviceModel: 'SOCKET_SERVER'
                },
                {DeviceType: 'SERIAL_PORT', DeviceName: '串口设备', icon: 'SERIAL_PORT', DeviceModel: 'SERIAL_PORT'}
            ]
        }
    ]

    static COMMON = {
        DATA_TYPE: ['int', 'long', 'string', 'bool', 'float', 'object', 'dynamic '],
        MES_DATA_TYPE: [' ', 'NUMBER', 'TEXT', 'FORMULA', 'BOOLEAN', 'LIST'],
        COMPARISON_OPERATORS: [
            {value: 'ET', tip: '等于'},
            {value: 'GT', tip: '大于'},
            {value: 'LT', tip: '小于'},
            {value: 'EMPTY', tip: '为空'},
            {value: 'NOT_EMPTY', tip: '不为空'},
            {value: 'BETWEEN', tip: '区间内'},
            {value: 'NOT_BETWEEN', tip: '区间外'},
            {value: 'CONTAINS', tip: '包含'},
            {value: 'NOT_CONTAINS', tip: '不包含'}
        ],
        ENCODING_FORMATS: [
            {value: 'UTF-8', tip: 'UTF-8'},
            {value: 'UTF-16', tip: 'UTF-16'},
            {value: 'GB2312', tip: 'GB2312'},
            {value: 'GBK', tip: 'GBK'}
        ],
        DATABASE_OPERATIONS: [
            {value: '新增', tip: 'INSERT'},
            {value: '修改', tip: 'UPDATE'},
            {value: '查询', tip: 'SELECT'},
            {value: '删除', tip: 'DELETE'}
        ],
        BUSINESS_USER_ROLE: [
            {value: 5, tip: '管理员', label: '管理员'}, // tip 后期弃用
            {value: 4, tip: 'ME', label: 'ME'},
            {value: 3, tip: 'PE', label: 'PE'},
            {value: 2, tip: '技师', label: '技师'},
            {value: 1, tip: '操作员', label: '操作员'}
        ],
        MATCHING_MODE: [
            {tip: '完全匹配(等于)', value: 'VALUE_EQUAL'},
            {tip: '发生变化', value: 'VALUE_CHANGE'},
            {tip: '部分匹配(包含)', value: 'VALUE_CONTAINS'},
            {tip: '不匹配(不等于)', value: 'VALUE_NOT_EQUAL'}],
        LOGIN_USER_INFO: 'LOGIN_USER_INFO',
        SYSTEM_CONFIG: 'SYSTEM_CONFIG',
        LOGOUT_TIME: 180000, // 180000
        USER_SCRIPT_TEMPLATE: '' +
            'using System;\n' +
            'using System.Text;\n' +
            'using System.Windows.Forms;\n' +
            'using Core.UserScript;\n' +
            'using Service.src.NW.Processor.Core;\n' +
            'using DatabaseCore.Modal;\n' +
            'using System.Collections.Generic;\n' +
            'using System.Threading;\n' +
            'public partial class NodeScript:RuntimeScript,INodeScript\n' +
            '{\n' +
            '    \n' +
            '    /// <summary>\n' +
            '    /// 节点被触发时，会自动执行当前函数\n' +
            '    /// </summary>\n' +
            '    /// <returns></returns>\n' +
            '    public bool Aspect()\n' +
            '    {\n' +
            '        //在方法内编辑脚本代码\n' +
            '\n' +
            '        return true;\n' +
            '    }\n' +
            '}\n' +
            '                            '
    }
}
